<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        ul{
            width: 420px;
            height: 140px;
            margin: 100px auto;
            list-style: none;
            background-color: aqua;
            display: flex;
        }
        ul>li{
            /* width: 100px;
            height: 100px; */
            flex: 1;
            text-align: center;
            line-height: 100px;
            margin: 20px;
            background-color: rebeccapurple;
        }
    </style>
</head>
<body>
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
    </ul>

    <script>
        // 事件委托
        // 1.获取ul元素
        var ul = document.querySelector('ul')
        // 2.给ul绑定事件
        ul.onclick = function(e){
            // console.log('1sad')
            // console.log(e.target)

            // 3.通过事件目标来判断你点击的是li
            if(e.target.tagName === 'LI'){
                console.log('li')
            }
        }
    </script>
</body>
</html>